package com.soladhoc.annonces.client.gin;

import com.google.inject.Provides;
import com.google.inject.Singleton;
import com.gwtplatform.mvp.client.gin.AbstractPresenterModule;
import com.gwtplatform.mvp.client.gin.DefaultModule;
import com.soladhoc.annonces.client.place.ClientPlaceManager;
import com.soladhoc.annonces.client.place.DefaultPlace;
import com.soladhoc.annonces.client.place.NameTokens;
import com.soladhoc.annonces.client.ui.AnnoncePresenter;
import com.soladhoc.annonces.client.ui.AnnonceView;
import com.soladhoc.annonces.client.ui.MainPagePresenter;
import com.soladhoc.annonces.client.ui.MainPageView;
import com.soladhoc.annonces.client.ui.OAuthPresenter;
import com.soladhoc.annonces.client.ui.OAuthView;
import com.soladhoc.annonces.shared.service.AnnonceRequestFactory;
import com.soladhoc.annonces.shared.service.AnnonceRequestFactory.AnnonceService;

public class ClientModule extends AbstractPresenterModule {

	@Override
	protected void configure() {
		install(new DefaultModule(ClientPlaceManager.class));

		bindPresenter(MainPagePresenter.class, MainPagePresenter.MyView.class,
				MainPageView.class, MainPagePresenter.MyProxy.class);

		bindConstant().annotatedWith(DefaultPlace.class).to(NameTokens.annonce);

		bindPresenter(OAuthPresenter.class, OAuthPresenter.MyView.class,
				OAuthView.class, OAuthPresenter.MyProxy.class);

		bindPresenter(AnnoncePresenter.class, AnnoncePresenter.MyView.class,
				AnnonceView.class, AnnoncePresenter.MyProxy.class);

//		bind(AuthFilter.class).in(Singleton.class);
		
		bind(AnnonceRequestFactory.class).in(Singleton.class);

	}
	
	@Provides
	AnnonceService providesAnnonceService(AnnonceRequestFactory requestFactory){
		return requestFactory.annonceService();
	}
}
